package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.PageDomain;
import com.zzyl.nursing.dto.DeviceDataMapDto;
import com.zzyl.nursing.dto.DeviceDto;
import com.zzyl.nursing.dto.UserAddRequestDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MemberElderVo;
import com.zzyl.nursing.vo.member.PropertyStatusInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @Autowired
    private IFamilyMemberElderService familyMemberElderService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    /**
     * 绑定老人
     * @param dto
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("绑定老人")
    public AjaxResult add(@RequestBody UserAddRequestDto dto) {
        familyMemberElderService.add(dto);
        return success();
    }

    /**
     * 查询家人列表
     * @param pageDomain
     * @return
     */
    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult queryFamilies(PageDomain pageDomain) {
        List<MemberElderVo> list = familyMemberElderService.queryFamilies(pageDomain);
        return success(list);
    }

    /**
     * 分页查询家人列表
     * @param pageDomain
     * @return
     */
    @GetMapping("/list-by-page")
    @ApiOperation("查询家人列表")
    public AjaxResult queryFamiliesDetails(PageDomain pageDomain) {
        List<MemberElderVo> list = familyMemberElderService.queryFamilies(pageDomain);
        return success(list);
    }

    /**
     * 查询家人健康数据
     * @param dto
     * @return
     */
    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询家人健康数据")
    public AjaxResult QueryDevicePropertyStatus(@RequestBody DeviceDto dto) {
        Map<String, PropertyStatusInfoVo> list = familyMemberElderService.QueryDevicePropertyStatus(dto);
        return success(list);
    }

    /**
     * 1.5  按天统计查询指标数据
     * @param dto
     * @return
     */
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public AjaxResult queryDeviceDataListByDay(DeviceDataMapDto dto) {
        List<Map<String, Object>> list = familyMemberElderService.queryDeviceDataListByDay(dto);

        return success(list);
    }

    /**
     * 1.5  按天统计查询指标数据
     * @param dto
     * @return
     */
    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataMapDto dto) {
        List<Map<String, Object>> list = familyMemberElderService.queryDeviceDataListByWeek(dto);

        return success(list);
    }

}
